{% extends "base_generic.html" %}

{% block content %}
  <h1>作者列表</h1>
  {% if author_list %}
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <div class="list-group">
          {% for author in author_list %}
            <div class="list-group-item book-list-item">
              <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">
                  <a href="{{ author.get_absolute_url }}">{{ author.last_name }}{% if author.first_name %}, {{ author.first_name }}{% endif %}</a>
                </h5>
                <small>
                  {% if author.date_of_birth %}出生: {{ author.date_of_birth }}{% endif %}
                  {% if author.date_of_death %} - 逝世: {{ author.date_of_death }}{% endif %}
                </small>
              </div>
              {% if author.books.all %}
                <p class="mb-1">著作: 
                  {% for book in author.books.all|slice:":3" %}
                    <a href="{{ book.get_absolute_url }}" class="badge badge-info">{{ book.title }}</a>
                  {% endfor %}
                  {% if author.books.all.count > 3 %}
                    <span class="badge badge-secondary">等{{ author.books.all.count }}部作品</span>
                  {% endif %}
                </p>
              {% endif %}
            </div>
          {% endfor %}
        </div>
      </div>
    </div>
  </div>
  {% else %}
    <p>图书馆中暂无作者信息。</p>
  {% endif %}
{% endblock %} 